package com.atguigu.spzx.cloud.user.service.impl;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.atguigu.spzx.cloud.user.entity.User;
import com.atguigu.spzx.cloud.user.mapper.UserMapper;
import com.atguigu.spzx.cloud.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;



    @Value("${server.port}")
    String port;
    @Override
    public User findUserByUserId(Long userId) {
        /*try {
            TimeUnit.SECONDS.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }*/
        User user = userMapper.findUserByUserId(userId);
        user.setAddress(user.getAddress()+"---"+port);
        return user;
    }

    @SentinelResource("user")
    @Override
    public void queryUsers(){
        System.err.println("查询用户");
    }


}
